<template>
	<view class="work_body">
		<view class="navbar">
			<view class="nav-item" :class="{ current: tabCurrentIndex === 1 }" @click="tabClick(1)">最新</view>
			<view class="nav-item" :class="{ current: tabCurrentIndex === 2 }" @click="tabClick(2)">价格</view>
			<view class="nav-item" :class="{ current: tabCurrentIndex === 3 }" @click="tabClick(3)">销量</view>
			<view class="nav-item" :class="{ current: tabCurrentIndex === 4 }" @click="tabClick(4)">人气</view>
		</view>
		<!-- 商品列表 v-if="tabCurrentIndex == 1"-->
		
		<view class="work_content"  v-for="(goods,index) in navList" :key="index"> 
			<view class="work_list">
				<!-- <image class="work_img" src="../../static/emptyCart.jpg" mode=""></image> -->
				<image class="work_img" :src="globalData.baseUrl+goods.goodsImg" mode=""></image>
				
				<view class="work_title">{{goods.name}}</view>
				<view class="work_price">￥{{goods.jiage}}</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabCurrentIndex: 1,
				navList: []
			}
		},
		onLoad() {
			this.goodsList();
		},
		methods: {
			tabClick(index){
				this.tabCurrentIndex = index
			},
			async goodsList() {
				const that = this
				that.$api.request('/system/webGoods','/listByUserId',{
					
				}, failres => {
					console.log("failres",failres);
					
					uni.showToast({
						title: failres.msg,
						icon: "none"
					});
				}).then(res => {
					console.log("then res",res);
					that.navList=res.rows;
					
				console.log(": " + JSON.stringify(res));
				
				})
				
			},
		}
	}
</script>

<style lang="scss">
	.work_body{
		background: #F6F6F6;
		min-height: 100vh;
		padding-top: 20upx;
		.navbar {
			display: flex;
			height: 40px;
			padding: 0 5px;
			background: #fff;
			box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
			position: relative;
			z-index: 10;
			.nav-item {
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
				height: 100%;
				font-size: 15px;
				color: $font-color-dark;
				position: relative;
				&.current {
					color: $base-color;
					&:after {
						content: '';
						position: absolute;
						left: 25%;
						bottom: 0;
						width: 44px;
						height: 0;
						border-bottom: 2px solid $base-color;
					}
				}
			}
		}
		.work_content{
			width: 96%;
			margin: 0 auto;
			margin-top: 30upx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
			.work_list{
				width: 49%;
				background: #FFFFFF;
				border-radius: 3upx;
				margin-bottom: 30upx;
				.work_img{
					width: 100%;
					height: 250upx;
					margin: 20upx 0;
				}
				.work_title{
					color: #333333;
					font-size: 34upx;
					margin-left: 20upx;
				}
				.work_price{
					color: #E93B3D;
					font-size: 32upx;
					margin-top: 20upx;
					margin-left: 20upx;
					margin-bottom: 20upx;
				}
			}
		}
	}
	
</style>
